/* 
 * File:   unixsocket.h
 * Author: robbiediaz
 *
 * Created on January 27, 2009, 5:29 PM
 */

#ifdef __APPLE__
#ifndef unix
#define unix 1
#endif
#endif

#ifdef linux
#ifndef unix
#define unix 1
#endif
#endif

#ifdef unix
#ifndef _UNIXSOCKET_H
#define	_UNIXSOCKET_H

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <sys/wait.h>
#include <signal.h>

#include "socket.h"
#include "../model/Peer.h"

class unixSocket : public genericSocket {
public:
    unixSocket();
    virtual ~unixSocket();
    void sendString(std::string msg);
    std::string readString(Peer* p);
    Peer* acceptConnection();
private:
    int sockfd;
    int new_fd;
    std::string port;
    struct sockaddr_storage their_addr;
    socklen_t addr_size;
    struct addrinfo hints, *res;
    sockaddr_in get_in_addr(struct sockaddr_storage &sa);
};

#endif	/* _UNIXSOCKET_H */
#endif